//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
   
  },
  //事件处理函数
  bindViewTap: function() {
    
  },
  onLoad: function () {
    wx.setNavigationBarTitle({
      title: '扫一扫',
    });
  },
  getUserInfo: function(e) {
   
  },
  // 扫码功能
  sweepCode(){
    wx.scanCode({
      success(res) {
        // console.log("11111");
        // 截取数字第一位
        let num = res.result
        num = num.substring(0, 1)
        console.log(num.result);
        if(num==1){
          wx.request({
            url: app.url + '/order/auth3/qrcoreUnfreezeRecord/selectDetail/' + res.result,
            method: 'GET',
            header: {
              token: wx.getStorageSync('token')
            },
            success: (e) => {
              if (e.data.code == 0) {
                wx.navigateTo({
                  url: '/pages/unfreeze/unfreeze?code=' + res.result
                })
              } else {
                wx.showModal({
                  title: '提示',
                  showCancel: false,
                  content: e.data.msg
                });
              }
            }
          }) 
        }else{
          wx.request({
            url: app.url + '/order/auth3/orderFormVerifyDetail/' + res.result,
            method: 'get',
            header: {
              token: wx.getStorageSync('token')
            },
            success: (e) => {
              if (e.data.code == 0) {
                wx.navigateTo({
                  url: '/pages/order-info/order-info?code=' + res.result
                })
              } else {
                wx.showModal({
                  title: '提示',
                  showCancel: false,
                  content: e.data.msg
                });
              }
            }
          })
       
        }
      
      }
    })
  },
  
})
